package com.mima.minaserver.server;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolManager {
	
	private static ExecutorService fixedThreadPool;
	private static ThreadPoolManager threadPoolExecutor;
	
	public static synchronized ThreadPoolManager getInstance(int poolSize) {
		if(threadPoolExecutor == null) {
			threadPoolExecutor = new ThreadPoolManager();
			initThreadPool(poolSize);
		}
		return threadPoolExecutor;
	}
	
	private static void initThreadPool(int size) {
		fixedThreadPool = Executors.newFixedThreadPool(size);
	}
	
	public ExecutorService getExecutorService() {
		return fixedThreadPool;
	}
	
	//暂时先不用
	public void stopFixedThreadPool() {
		
		fixedThreadPool.shutdown();
	}
	
	 
}
